package com.cs307.redcross.client;

import java.io.Serializable;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.RootPanel;

public class ContentPanel extends Composite implements Serializable {
	private static final long serialVersionUID = 7969012026813928897L;
	private LoadingPopupPanel lpp1 = new LoadingPopupPanel();
	private LoadingPopupPanel lpp2 = new LoadingPopupPanel();
	private LoadingPopupPanel lpp3 = new LoadingPopupPanel();
	public static Person currentUser;

	private RootPanel rootPanel;
	
	private static ContentPanel instance;
	public static ContentPanel getInstance() {
		if (instance == null)
			instance = new ContentPanel();
		
		return instance;
	}
	
	private ContentPanel() {
		rootPanel = RootPanel.get("content");
	}
	
	public void setContent(Content content) {
		rootPanel.clear();
		rootPanel.add(content);
		lpp1.hide();
		lpp2.hide();
		lpp3.hide();
	}
	
	public void showLoading(int popup, int leftPos, int rightPos) {
		if (popup == 1) {
			lpp1.setPopupPosition(leftPos, rightPos);
			lpp1.setModal(true);
			lpp1.show();
		}
		else if (popup == 2) {
			lpp2.setPopupPosition(leftPos, rightPos);
			lpp2.setModal(true);
			lpp2.show();
		}
		else if (popup == 3) {
			lpp3.setPopupPosition(leftPos, rightPos);
			lpp3.setModal(true);
			lpp3.show();
		}		
	}	
	
	public void hideLoadingPopup(int popup) {
		if (popup == 1) {
			lpp1.hide();
		}
		else if (popup == 2) {
			lpp2.hide();
		}
		else if (popup == 3) {
			lpp3.hide();
		}	
	}
}
